#include "StdAfx.h"
#include "testWeapon.h"
#include "testBullet.h"
#include "WeaponFireManager.h"

//=>Physics
#include "PhysicsPropertyMessages.h"
//<=
//=>Collision
#include "CollisionMessages.h"
//<=

namespace _DATAPART_
{
	namespace _GAME_
	{
		FoImplementRTTI(testWeapon,::_DATAPART_::_GAME_::Weapon);
		testWeapon::testWeapon(void)
		{
		}

		testWeapon::~testWeapon(void)
		{
		}

		void testWeapon::Fire(_FOMATH::Vector &fireLocation)
		{
			_FOGGE_::_GDB_::foDataObject* newObject=m_ptrBulletTemplete->GetOwner()->Clone();


			_P_GAME::Bullet* newBullet=FoDynamicCast(_P_GAME::Bullet,newObject->GetDataPart(_FOGGE_::eEMID_Game));


		//	SendSetCollisionCheckMessage(false,GetAncestor()->GetOwner(),newBullet->GetOwner());


			newBullet->GetOwner()->ActivateDataObject();

			
			_FOMATH::Vector vel=_FOMATH::DIRECTION_FRONT*1000;
			
			newBullet->SetDesiredLocation(GetFireStartLocation());

			newBullet->SetDesiredRotation(GetRotation());


		//	SendChangeVelocityMessage(newBullet,vel);

			g_ptrWeaponFireManager->AddFiredBullet(newBullet);
			
		}
	}
}

namespace _DATAPARTFACTORY_
{
	namespace _GAME_
	{
		testWeaponFactory::testWeaponFactory(void)
		{
			m_Name=__T("testWeaponGamePart");
		}
		testWeaponFactory::~testWeaponFactory(void)
		{
		}
		_FOGGE_::_GDB_::aDataPartBase* testWeaponFactory::GetNewPart()
		{
			return foNEW _P_GAME::testWeapon();
		}


		_FOGGE_::_GDB_::aDataPartBase* testWeaponFactory::LoadPart(TiXmlNode* ptrNode)
		{
			_P_GAME::testWeapon* ptrNewPart=FoDynamicCast(_P_GAME::testWeapon,__super::LoadPart(ptrNode));

		

			return ptrNewPart;
		}
			
		_FOGGE_::_GDB_::aDataPartBase* testWeaponFactory::CreatePart()
		{
			_P_GAME::testWeapon* ptrNewPart=FoDynamicCast(_P_GAME::testWeapon,__super::CreatePart());

		

			return ptrNewPart;
		}

	}
}
